var lastHeight = 0;
$(document).ready(function(){
		$("#main_iframe").load(function(){
			var mainheight = $(this).contents().find("body").height()+200;
      if(mainheight == 200) mainheight = 1000;
			$(this).height(mainheight);
			//记录本次iframe的高度
			lastHeight = mainheight;

			//当检测到click事件时，判断iframe高度是否有变化
			$($("#main_iframe")[0].contentWindow).click(function(){reLoad()});
			initNum();
		});
		$(".menulistclick").click(function() { //用户点击左侧菜单 永久改变菜单颜色
			$(".menulistclick").removeClass("menulistblack");
			$(this).addClass("menulistblack");
		});
		//三级菜单
		$("#mG_sidebar .sm_title").click(function() {
			if ($(this.parentNode).attr("class") == "") {
				$(this.parentNode).attr("class", "sub_menu current");
			}else {
				$(this.parentNode).attr("class", "");
			}
		});
});
//主要由框架内的页面高度变化后通过parent.reLoad()来通新扩展框架页高度
function reLoad(){
	window.setTimeout(function(){
		var obj = $("#main_iframe");
		var mainheight = obj.contents().find("body").height()+200;
		//当检测到高度变化了，才改变iframe高度
		if(mainheight != lastHeight){
			obj.height(mainheight);
			//同时记录本次iframe高度
			lastHeight = mainheight;
		}
	},100);
}
//强制设置框架高度
function setFrameHeight(h){
	var obj = $("#main_iframe");
	obj.height(h);
}
function initNum(){
	var now_url = location.href;
	if(now_url.substr(-3) == 's=1'){ //只在标签选择 举报管理时加在aj_complaint.php
		countComplaint();	//complaint
	}
}

function toggleFrame(){
  var leftbar = document.getElementById("mG_sidebar");
  var icon     = document.getElementById("left_icon");
  var show    = "images/left_show.gif";
  var hide    = "images/left_hidden.gif";
  var right  = document.getElementById("ADM_right");
  var left_hidden = document.getElementById("left_hidden");

  if(leftbar.style.display == "none"){
    icon.src = hide;
    leftbar.style.display = "";
    right.style.marginLeft = "244px";
    left_hidden.style.left = "191px";

  }else{
    icon.src = show;
    leftbar.style.display = "none";
    right.style.marginLeft = "25px";
    left_hidden.style.left = "0px";
  }
}